<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>P193 8.3.4【案例】鼠标拖拽特效</title>
</head>

<body>
    <div id="box" class="box">
        <div id="drop" class="hd">注册信息（可以拖拽）
            <span id="box_close">【关闭】</span>
        </div>
        <div class="bd"></div>
    </div>
    <script>
        var box = document.getElementById('box');
        var drop = document.getElementById('drop');
        drop.onmousedown = function (event) {
            var event = event || window.event;
            var pageX = event.pageX || event.clientX + document.documentElement.scrollLeft;
            var pageY = event.pageY || event.clientY + document.documentElement.scrollTop;
            var spaceX = pageX - box.offsetLeft;
            var spaceY = pageY - box.offsetTop;
            document.onmousemove = function (event) {
                var event = event || window.event;
                var pageX = event.pageX || event.clientX + document.documentElement.scrollLeft;
                var pageY = event.pageY || event.clientY + document.documentElement.scrollTop;
                box.style.left = pageX - spaceX + 'px';
                box.style.top = pageY - spaceY + 'px';
                if (window.getSelection) {
                    window.getSelection().removeAllRanges();
                } else {
                    document.selection.empty();
                }
                document.onmouseup = function () {
                    document.onmousemove = null;
                };
            };
        };
    </script>
    <a href="../首页/page08.html">
        <h2>返回上一页面</h2>
    </a>
</body>

</html>